package com.wanmait.recruit.service.impl;

import com.github.pagehelper.PageInfo;
import com.wanmait.recruit.pojo.Resume;
import com.wanmait.recruit.service.WorkExpService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import com.wanmait.recruit.pojo.WorkExp;
import com.wanmait.recruit.mapper.WorkExpMapper;
import org.springframework.transaction.annotation.Transactional;

@Service("workExpService")
@Transactional(rollbackFor = Exception.class)
public class WorkExpServiceImpl implements WorkExpService {

    @Resource
    private WorkExpMapper workExpMapper;

    public int deleteByPrimaryKey(Integer id){
        return workExpMapper.deleteByPrimaryKey(id);
    }

    public void insert(WorkExp record){
        workExpMapper.insert(record);
    }

    @Override
    public void delete(WorkExp object) {

    }

    @Override
    public void update(WorkExp object) {
        workExpMapper.updateByPrimaryKey(object);
    }

    @Override
    public PageInfo<WorkExp> search(int pageNum, int pageSize) {
        return null;
    }

    public int insertSelective(WorkExp record){
        return workExpMapper.insertSelective(record);
    }

    public WorkExp selectByPrimaryKey(Integer id){
        return workExpMapper.selectByPrimaryKey(id);
    }

    public int updateByPrimaryKeySelective(WorkExp record){
        return workExpMapper.updateByPrimaryKeySelective(record);
    }

    public int updateByPrimaryKey(WorkExp record){
        return workExpMapper.updateByPrimaryKey(record);
    }

    @Override
    public WorkExp findByResume(Resume resume) {
        return workExpMapper.findByResumeId(resume.getId());
    }

    @Override
    public boolean findIsWorkExp(Integer resumeId) {
        ArrayList<WorkExp> allByResumeId = workExpMapper.findAllByResumeId(resumeId);
        if (allByResumeId.size()==0){return false;}
        else {return true;}
    }

    @Override
    public ArrayList<WorkExp> findWorkExp(Integer resumeId) {
        return workExpMapper.findAllByResumeId(resumeId);
    }

    @Override
    public void delWorkExp(Integer id) {
        workExpMapper.updateDelById(id);
    }
}
